<template>
  <div class="newPeople">
    <div class="newPeople-wrap">
      <div class="newPeople-content-wrap">
        <div class="newPeople-header">
          <img
            src="~assets/img/activity/newPeople.png"
            alt=""
          >
        </div>
        <div class="newPeople-content">
          <div
            v-for="item in list"
            :key="item.product_id"
            class="product-list-content-item"
          >
            <ProjectList
              :project-data="item"
              :acivity="true"
              @isAlert="isAlertBlock"
            />
          </div>
        </div>
      </div>
      <Pager
        :page-config="pageConfig"
        @changeCurrentPage="changeCurrentPage"
      />
    </div>
    <div
      v-if="isAlert"
      class="mask"
    >
      <div class="mask-box">
        <img
          src="~assets/img/activity/code.jpg"
          alt=""
          class="newPeople-code"
        >
        <div class="mask-text-one">
          添加容猫官方客服
        </div>
        <div class="mask-text-two">
          领新人<span>2999</span>元变美礼包
        </div>
      </div>
      <img
        src="~assets/img/activity/close.png"
        alt=""
        class="close"
        @click="isAlertNone"
      >
      <iframe
        :src="product_id?`/activity/product/${product_id}`:'/activity/customerService'"
        class="iframes"
      />
    </div>
    <div
      class="customer-service-wrap"
      @click="AlertBlock"
    >
      <img
        src="~/assets/img/activity/customer-service.png"
        alt=""
        class="customer-service"
      >
    </div>
  </div>
</template>
<script>
import ProjectList from '@/components/activityProjectList'
import { newPeopleLiposuction } from '@/api/activity'
import Pager from '@/components/pagerTwo'
// import { Burying } from '@/utils/burying'
export default {
  components: {
    ProjectList,
    Pager
  },
  data() {
    return {
      listQuery: {
        page: 1,
        per_page: 12,
        product_group_id: '5006414B42277'
      },
      list: [],
      pageConfig: {
        pageNo: 1,
        pageSize: 10,
        total: 0,
        pageTotal: 0
      },
      isAlert: false,
      num: 1,
      product_id: ''
    }
  },
  computed: {

  },
  created() {
    if (this.$route.query.channel === '2A44FDD9EE93BDF9') {
      // 来自360埋点
    }
    this.getData(1)
  },
  mounted() {
  },
  methods: {
    getData(page) {
      this.listQuery.page = page
      newPeopleLiposuction(this.listQuery).then(res => {
        if (res.data.length) {
          this.list = res.data
          this.pageConfig.total = res.meta.total
          this.pageConfig.pageTotal = res.meta.last_page
          this.productData = res.data
        } else {
          this.list = []
        }
      })
    },
    changeCurrentPage(page) {
      this.pageConfig.pageNo = page
      this.getData(page)
    },
    isAlertBlock({ Alerts, product_id }) {
      this.isAlert = Alerts
      this.product_id = product_id
    },
    AlertBlock() {
      this.isAlert = true
    },
    isAlertNone() {
      this.isAlert = false
    }
  },
  head() {
    return {
      title: '容猫-2999元整形大礼包免费领',
      meta: [
        { hid: 'description',
          name: 'description',
          content: '容猫-2999元整形大礼包免费领'
        }, {
          name: 'keywords', content: '容猫-2999元整形大礼包免费领'
        }
      ]
      // script: [
      //   { src: '//hm.baidu.com/hm.js?78049c6e26afc3c63954ac4da03e3844' }
      // ]
    }
  }
}
</script>
<style scoped lang="scss">
.newPeople {
  width: 100%;
  background: #c382f8;
  padding-bottom: 10px;
  .newPeople-wrap {
    width: 1190px;
    margin: 0 auto;
    background: #fff;
    padding-bottom: 40px;
  }
}
.newPeople-content {
  display: flex;
  flex-wrap: wrap;
  .product-list-content-item {
    margin-left: 10px;
  }
}
.mask {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.3);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  .mask-box {
    width: 309px;
    height: 318px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    box-shadow: 0px 0px 10px 0px rgba(71, 114, 228, 0.51);
    border-radius: 10px;
  }
  .newPeople-code {
    width: 179px;
    height: 181px;
    margin-top: 30px;
    margin-left: 65px;
  }
  .mask-text-one {
    font-size: 24px;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    line-height: 33px;
    text-align: center;
    margin-top: 19px;
  }
  .mask-text-two {
    font-size: 18px;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    line-height: 25px;
    margin-top: 6px;
    text-align: center;
    > span {
      color: #ff3b58;
    }
  }
  .close:hover {
    cursor: pointer;
  }
  .close {
    width: 20px;
    height: 20px;
    position: absolute;
    top: 25%;
    left: 65%;
  }
}
.iframes {
  width: 10px;
  height: 10px;
  opacity: 0;
}
.customer-service-wrap {
  position: fixed;
  bottom: 50%;
  right: 2%;
}
</style>
